package JavaBase;
/*
定义一个员工（Employee）类，该类的属性有员工编号（Id）、姓名（Name）、底薪（Salary）
，所在部门（Department，该属性的值为Department类的对象）。
    然后为员工类定义一个计算工资（countSalary）的方法，
    该方法的参数为本月销售额（sales），返回值为该员工的月工资。
    月工资的计算方法为：底薪+销售提成，
    销售提成的比例如下：小于10w为1%，10w至20w为2%，大于等于20w为3%。
 */
public class Employee1 {

    private int id;
    private String name;
    private double salary;
    Department department;
    public Employee1()
    {
        this.id=1;
        this.name="打火机";
        this.salary=3000;
        this.department=new Department(2,"红烧");
    }
    public Employee1(int id,String name,double salary,Department department)
    {
        this.id=id;
        this.name=name;
        this.salary=salary;
        this.department=department;
    }

    public void showPrint()
    {
        System.out.println("***员工信息***");
        System.out.println("员工编号："+this.id);
        System.out.println("员工姓名："+this.name);
        System.out.println("所在部门编号:"+this.department.getId());
        System.out.println("所在部门名称："+this.department.getName());
    }
    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public double getSalary() {
        return salary;
    }

    public int getId() {
        return id;
    }

    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }
    public  double countSalary(Double monthSale)
    {
        double addtional=0;
        if(monthSale>0&&monthSale<10)
        {
            addtional=monthSale*0.01;
        }
        else if(monthSale>=10&&monthSale<=20)
        {
            addtional=monthSale*0.02;
        }
        else if(monthSale>20)
        {
            addtional=monthSale*0.03;
        }
        else
        {
            System.out.println("销售额输入错误！");
        }
        double sumMoney=this.salary+addtional;
        return sumMoney;
    }

}
